package com.gzbit.calculator.simplefactory;

import com.gzbit.calculator.bll.AddOperation;
import com.gzbit.calculator.bll.IOperation;
import com.gzbit.calculator.bll.MulOperation;
import com.gzbit.calculator.bll.SubOperation;

public class SimpleFactory {
     private IOperation opr =null;
     public IOperation getOperation(String oprType)throws Exception{

        switch(oprType){
            case "+":
                opr=new AddOperation();  //相当于生产对象
                break;
            case "-":
                opr=new SubOperation();
                break;
            case "*":
                opr= new MulOperation();
            default:
                throw new Exception("输入的运算符号错误！");

        }
        return opr;
    }
}
